package cn.mw.cmdb.trigger;

import cn.mw.cmdb.entity.PropertyTypeString;
import cn.mw.cmdb.entity.PropertyTypeTime;
import cn.mw.components.mongodb.anno.CMDBProperty;
import lombok.Builder;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

@Builder
@Data
@Document("mw_cmdbmd_trigger")
public class MwCmdbTrigger {

    //分组路径
    private List<String> groupPath;

    //所属模型分组
    private String modelGroupId;

    //所属模型
    private String modelId;

    //模型名称
    private String modelName;

    //字段名
    private String fieldName;

    //字段描述
    private String fieldDesc;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String triggerType;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String bussinessId;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String bussinessType;

    //业务名称
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String bussinessName;

    @CMDBProperty(searchType = PropertyTypeTime.ID)
    private Date trigDate;

    private Map<String ,Object> data;

    public void addData(String key, String value){
        if(null == data){
            data = new HashMap<>();
        }
        data.put(key ,value);
    }
}
